* Tables in Appendix. 
* Author: Xiao Wang
* Version: 07/2020

cd "C:\Users\Xiao\Box\TRI_relocation_project\Paper1\Replication_kit"

* Do the cross-sectional regressions 

use data_crs_regs, clear
 
* -------------------------
* Summary statistics (Table B2)

count if move199020 == 1 // N = 2,678
count if move199020_ct == 1 // N = 1,343
count if move199020_cnty == 1 // N = 1,335

foreach i of varlist lgpcinc_ctnb edu3_rate_ctnb whitenonhis_ratenb voterturnoutnb demo_ratenb lgpopdensity_ctnb ageunder5_rate_ctnb age4_rate_ctnb hrenter_ratenb hvac_ratenb NA NTRI_ctnb lgwageindcnty highwaymiles2001nb railmiles2003nb urban_rate_ctnb housingvalue_adj1990nb ETFnb lgemp totalrelt paydexmax paydexdiff   {

	ttest `i', by(move199020)
	
	}
	
* --------------------------
* Regressions 

set matsize 3500
set more off

// Gen Linear Splines 
capture drop sp* 
_pctile l2totalrelt, p(65 75 90 95)
mkspline sp1 `r(r1)' sp2 `r(r2)' sp3 `r(r3)' sp4 `r(r4)' sp5 = l2totalrelt, di 

label var sp1 "Emis < 65th pct"
label var sp2 "Emis 65th to 75th pct"
label var sp3 "Emis 75th to 90th pct"
label var sp4 "Emis 90th to 95th pct"
label var sp5 "Emis > 95th pct"

// Independent vars
global x1 "lgemp"
global x2 "paydexdiff paydexmax"
 
global m1nb "lgpopdensity_ctnb"
global m2nb "lgpcinc_ctnb edu3_rate_ctnb"
//global m2nb "lgmhincnb edu3_rate_ctnb" // Can test for robustness if using median household income instead of per capita income
global m3nb "whitenonhis_ratenb voterturnoutnb demo_ratenb"
global m31nb "whitenonhis_ratenb"

global z1 "NA"
global z2nb "NTRI_ctnb"
global z3nb "lgwageindcnty highwaymiles2001nb railmiles2003nb urban_rate_ctnb housingvalue_adj1990nb" 
global z31nb "highwaymiles2001nb railmiles2003nb urban_rate_ctnb housingvalue_adj1990nb" 


* ---------------------------------------------
* Table B3. Crs-sectional regression T = 5, 10
* ---------------------------------------------
eststo crs_50: qui logit move19905 $m2nb $m3nb $m1nb $x1 $x2 i.stateID i.sic2digm, cluster(tractID) 
eststo crs_51: qui logit move19905 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl i.stateID i.sic2digm, cluster(tractID)
eststo crs_52: qui logit move19905 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

eststo crs_100: qui logit move199010 $m2nb $m3nb $m1nb $x1 $x2 i.stateID i.sic2digm, cluster(tractID) 
eststo crs_101: qui logit move199010 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl i.stateID i.sic2digm, cluster(tractID)
eststo crs_102: qui logit move199010 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

esttab crs_50 crs_51 crs_52 crs_100 crs_101 crs_102 using TableB3.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	mtitle("Moved in 5 Years" "" "" "Moved in 10 years" "" "") ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)


* ------------------------------
* Table B4. Robustness checks: add %children, %Elders, %Renters, %Vacancy, %moving in 5 years, %manufacturing emp. col (1) (2)
* ------------------------------
global mextra "ETFnb ageunder5_rate_ctnb age4_rate_ctnb hrenter_ratenb hvac_ratenb movein5yrsless_rentnb poverty_ctnb manuf_emp_rate_ctnb"

eststo crs_more10: qui logit move199010 $m2nb $m3nb $m1nb $mextra $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

eststo crs_more20: qui logit move199020 $m2nb $m3nb $m1nb $mextra $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

esttab crs_more10 crs_more20 using TableB4.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)
	

* ------------------------------------------------------------
* Table B5. Robustness checks on the effect of CAAA on HAPs. Col (1) (2)
* ------------------------------------------------------------
eststo hap10: qui logit move199010 $m2nb $m3nb $m1nb $x1 HAP_ratio sp* zero_tl $x2 $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

eststo hap20: qui logit move199020 $m2nb $m3nb $m1nb $x1 HAP_ratio sp* zero_tl $x2 $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

esttab hap10 hap20 using TableB5.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)	
	
	
* -------------------------------------------------------------------------------------------
* Table B6. Robustness checks: spatial autocorrelation. County random effects. Col (1), (2)
* -------------------------------------------------------------------------------------------
eststo re10: qui melogit move199010 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID || cntyID:
eststo re20: qui melogit move199020 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID || cntyID:

esttab re10 re20 using TableB6.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	mtitle("Moved in 10 Years" "Moved in 20 years") ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)
*	
	
* -----------------------------------------------------------------------
* Table B7. Sensitivity test on explanatory var, except col (3), (6), (9)
* -----------------------------------------------------------------------
set more off 
global m2nbs1 "lgpcinc_ctnb"
global m3nbs1 "whitenonhis_ratenb voterturnoutnb"

eststo crs_sens101: qui logit move199010 $m2nbs1 $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo crs_sens201: qui logit move199020 $m2nbs1 $m3nb $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.stateID i.sic2digm, cluster(tractID) 
eststo crs_sens102: qui logit move199010 $m2nb $m3nbs1 $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo crs_sens202: qui logit move199020 $m2nb $m3nbs1 $m1nb $x1 $x2 sp* zero_tl $z1 $z2nb $z3nb i.stateID i.sic2digm, cluster(tractID) 
eststo crs_sens103: qui logit move199010 $m2nb $m3nb $m1nb $x1 sp* zero_tl $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo crs_sens203: qui logit move199020 $m2nb $m3nb $m1nb $x1 sp* zero_tl $z1 $z2nb $z3nb i.stateID i.sic2digm, cluster(tractID) 

esttab crs_sens101 crs_sens201 crs_sens102 crs_sens202 crs_sens103 crs_sens203 using TableB7.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)

* ------------------------------------------ 
* Table B9. Crs-sec regs with interactions
* ------------------------------------------
local intpop "1.zero_tl#c.lgpopdensity_ctnb c.sp1#c.lgpopdensity_ctnb c.sp2#c.lgpopdensity_ctnb c.sp3#c.lgpopdensity_ctnb c.sp4#c.lgpopdensity_ctnb c.sp5#c.lgpopdensity_ctnb"
local intedu "1.zero_tl#c.edu3_rate_ctnb c.sp1#c.edu3_rate_ctnb c.sp1#c.edu3_rate_ctnb c.sp2#c.edu3_rate_ctnb c.sp3#c.edu3_rate_ctnb c.sp4#c.edu3_rate_ctnb c.sp5#c.edu3_rate_ctnb"

eststo intcrs_101: qui logit move199010 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcrs_102: qui logit move199010 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcrs_201: qui logit move199020 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcrs_202: qui logit move199020 $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

eststo intcntycrs_101: qui logit move199010_cnty $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcntycrs_102: qui logit move199010_cnty $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcntycrs_201: qui logit move199020_cnty $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)
eststo intcntycrs_202: qui logit move199020_cnty $m2nb $m3nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z1 $z2nb $z3nb i.sic2digm i.stateID, vce(cluster tractID)

eststo intcrsct_101: qui logit move199010_ct $m2nb $m31nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z2nb $z31nb i.sic2digm i.stateID /// 
	if maxmove_cnty == 0 & lgwageindcnty ~= . & voterturnout ~= ., cluster(tractID) 
eststo intcrsct_102: qui logit move199010_ct $m2nb $m31nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z2nb $z31nb i.sic2digm i.stateID /// 
	if maxmove_cnty == 0 & lgwageindcnty ~= . & voterturnout ~= ., cluster(tractID) 
eststo intcrsct_201: qui logit move199020_ct $m2nb $m31nb $m1nb $x1 $x2 sp* zero_tl `intpop' $z2nb $z31nb i.sic2digm i.stateID /// 
	if maxmove_cnty == 0 & lgwageindcnty ~= . & voterturnout ~= ., cluster(tractID) 
eststo intcrsct_202: qui logit move199020_ct $m2nb $m31nb $m1nb $x1 $x2 sp* zero_tl `intedu' $z2nb $z31nb i.sic2digm i.stateID /// 
	if maxmove_cnty == 0 & lgwageindcnty ~= . & voterturnout ~= ., cluster(tractID) 
outreg2 using intcrs.doc, label append drop(i.sic2digm i.stateID) dec(3) ctitle(Moved in 20 yrs) addtext(Industry FE, YES, State FE, YES) 

local intlist 1.zero_tl#c.lgpopdensity_ctnb 1.zero_tl#c.edu3_rate_ctnb c.sp1#c.lgpopdensity_ctnb c.sp1#c.edu3_rate_ctnb c.sp2#c.lgpopdensity_ctnb c.sp2#c.edu3_rate_ctnb c.sp3#c.lgpopdensity_ctnb c.sp3#c.edu3_rate_ctnb c.sp4#c.lgpopdensity_ctnb c.sp4#c.edu3_rate_ctnb c.sp5#c.lgpopdensity_ctnb c.sp5#c.edu3_rate_ctnb

esttab intcrs_101 intcrs_102 intcrs_201 intcrs_202 intcntycrs_101 intcntycrs_102 intcntycrs_201 intcntycrs_202 intcrsct_101 intcrsct_102 intcrsct_201 intcrsct_202 using TableB9.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	mtitle("Moved in 10 Years" "" "Moved in 20 years" "" "Moved in 10 Years" "" "Moved in 20 years" "" "Moved in 10 Years" "" "Moved in 20 years" "") ///
	label interaction(" x ") b(3) rename($intlist) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)
	

* ------------------------------------------
* Table B12. Heterogeneity across Industries
* ------------------------------------------
preserve 
replace sic2digm = 100 if inlist(sic2digm, 16, 17, 42, 50, 59, 73, 76, 87)
eststo indFE10: logit move199010 c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)
eststo indFE20: logit move199020 c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl  $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)

eststo indFEcnty10: logit move199010_cnty c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)
eststo indFEcnty20: logit move199020_cnty c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl  $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)

eststo indFEct10: logit move199010_ct c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)
eststo indFEct20: logit move199020_ct c.lgpopdensity_ctnb#ib100.sic2digm c.edu3_rate_ctnb#ib100.sic2digm $m2nb $m3nb $m1nb $x1 sp* zero_tl  $x2 $z1 $z2nb $z3nb ib100.sic2digm i.stateID, vce(cluster tractID)

esttab indFE10 indFE20 indFEcnty10 indFEcnty20 indFEct10 indFEct20 using TableB12.csv, replace ///
	drop(*.sic2digm *.stateID) ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)
restore 



* ----------------------------------------------
* Do panel regressions

use data_panel_regs, clear 
xtset facilityID year
* -------------------
** Regressions 
* -------------------

* Covariates 
global x1 "lgemp"
global x2 "paydexdiff paydexmax"
 
global m1nb "lgpopdensity_ctnb1990"
global m2nb "lgpcinc_ctnb1990 edu3_rate_ctnb1990"
global m3nb "whitenonhis_ratenb1990 voterturnoutnb1990 demo_ratenb1990 "
global m31nb "whitenonhis_ratenb1990"

global z1 "NA"
global z2nb "NTRI_ctnb"
global z3nb "lgwageindcnty highwaymiles2001nb1990 railmiles2003nb1990 urban_rate_ctnb1990 housingvalue_adj1990nb1990" 
global z31nb "highwaymiles2001nb1990 railmiles2003nb1990 urban_rate_ctnb1990 housingvalue_adj1990nb1990" 

capture drop sp1 sp2 sp3 sp4 sp5 
mkspline sp1 1.5 sp2 15.36 sp3 104.64 sp4 279.24 sp5 = l2totalrelt, di 
	// same as the cross-sectional regression spline points

label var sp1 "Emis < 65th pct"
label var sp2 "Emis 65th to 75th pct"
label var sp3 "Emis 75th to 90th pct"
label var sp4 "Emis 90th to 95th pct"
label var sp5 "Emis > 95th pct"



* ------------------------------------------------- 
* Table B4. Col (3)
* --------------------------------------------------
global m12nb "ageunder5_rate_ctnb1990 age4_rate_ctnb1990"
global m32nb "ETFnb1990"
global m33nb "hrenter_ratenb1990 hvac_ratenb1990 movein5yrsless_ownnb1990"
global m34nb "manuf_emp_rate_ctnb1990 below_poverty_rate_ct90nb1990"

eststo tb3: qui logit moving_ctcnty $m2nb $m3nb $m1nb $m12nb $m32nb $m33nb $m34nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID i.sic2digm i.year, vce(cluster tractID)

esttab tb3 using TableB4.csv, append ///
	drop(*.sic2digm *.stateID *.year) ///
	label interaction(" x ") b(3) ar2 se star(* 0.10 ** 0.05 *** 0.01) ///
	nogap nodep nonotes compress 

	
* ------------------------------ 
* Table B5. Add HAP, col (3)
* ------------------------------
sort facilityID year
eststo pl_hap: qui logit moving_ctcnty $m2nb $m3nb $m1nb l.($x1) sp* zero_tl HAP_ratio l.($x2 $z1 $z2nb $z3nb) i.year i.sic2digm i.stateID, vce(cluster tractID)

esttab pl_hap using TableB5.csv, append ///
	drop(*.sic2digm *.stateID  *.year) ///
	label interaction(" x ") b(3) ar2 se star(* 0.10 ** 0.05 *** 0.01) ///
	nogap nodep nonotes compress 
	
* ----------------- 
* Table B6. Col (3)
* -----------------
eststo pl_r1: melogit moving_ctcnty $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID i.sic2digm i.year || cntyID: 

esttab pl_r1 using TableB6.csv, append ///
	drop(*.sic2digm *.stateID) ///
	mtitle("Moved in year t") ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress ar2 se star(* 0.10 ** 0.05 *** 0.01)
*

	
* ---------------------------
* Table B7. Col (3) (6) (9)
* ---------------------------
set more off 
global m2nbs1 "lgpcinc_ctnb1990"
global m3nbs1 "whitenonhis_ratenb1990 voterturnoutnb1990"

eststo pl_s1: qui logit moving_ctcnty $m2nbs1 $m3nb $m1nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID i.sic2digm i.year, vce(cluster tractID)
eststo pl_s2: qui logit moving_ctcnty $m2nb $m3nbs1 $m1nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID i.sic2digm i.year, vce(cluster tractID)
eststo pl_s3: qui logit moving_ctcnty $m2nb $m3nb $m1nb l.($x1) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID i.sic2digm i.year if e(sample) == 1, vce(cluster tractID)

esttab pl_s1 pl_s2 pl_s3 using TableB7.csv, append ///
	drop(*.sic2digm *.stateID *.year) ///
	label interaction(" x ") b(3) ar2 se star(* 0.10 ** 0.05 *** 0.01) ///
	nogap nodep nonotes compress 

	

* ----------------------------------------------
* Table B8. Endogeneity of Toxic Emission Level
* ----------------------------------------------
sort facilityID year
capture drop l5*
capture drop y88*
forv i = 1(1)5 {
	
	by facilityID: gen l5sp`i' = l3.sp`i'
	by facilityID: gen y88sp`i' = sp`i'[1]
	}

by facilityID: gen l5zero_tl = l5.zero_tl 
by facilityID: gen y88zero_tl = zero_tl[1]

eststo tb5_l5: qui ivprobit moving_ctcnty $m2nb $m3nb $m1nb l.($x1) l.($x2 $z1 $z2nb $z3nb) i.year i.sic2digm i.stateID (sp1 sp2 sp3 sp4 sp5 zero_tl = l5sp1 l5sp2 l5sp3 l5sp4 l5sp5 l5zero_tl), vce(cluster tractID)
codebook facilityID if e(sample) == 1
margins, dydx(lgpopdensity_ctnb1990 edu3_rate_ctnb1990 l.lgwageindcnty) at((mean)_all)  

eststo tb5_y88: qui ivprobit moving_ctcnty $m2nb $m3nb $m1nb l.($x1) l.($x2 $z1 $z2nb $z3nb) i.year i.sic2digm i.stateID (sp1 sp2 sp3 sp4 sp5 zero_tl = y88sp1 y88sp2 y88sp3 y88sp4 y88sp5 y88zero_tl), vce(cluster tractID)

esttab tb5_l5 tb5_y88 using TableB8.csv, replace ///
	drop(*.sic2digm *.stateID *.year) ///
	label interaction(" x ") b(3) se ar2 star(* 0.10 ** 0.05 *** 0.01) ///
	nogap nodep nonotes compress 
	
	
* ------------------
* Table B10
* ------------------
local intpop "1.zero_tl#c.lgpopdensity_ctnb1990 c.sp1#c.lgpopdensity_ctnb1990 c.sp2#c.lgpopdensity_ctnb1990 c.sp3#c.lgpopdensity_ctnb1990 c.sp4#c.lgpopdensity_ctnb1990 c.sp5#c.lgpopdensity_ctnb1990"

local intedu "1.zero_tl#c.edu3_rate_ctnb1990 c.sp1#c.edu3_rate_ctnb1990 c.sp2#c.edu3_rate_ctnb1990 c.sp3#c.edu3_rate_ctnb1990 c.sp4#c.edu3_rate_ctnb1990 c.sp5#c.edu3_rate_ctnb1990"

eststo intpl_1: qui logit moving_ctcnty $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl `intpop') l.($z1 $z2nb $z3nb) i.sic2digm i.year i.stateID, vce(cluster tractID)
eststo intpl_2: qui logit moving_ctcnty $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl `intedu') l.($z1 $z2nb $z3nb) i.sic2digm i.year i.stateID, vce(cluster tractID)
eststo cntyintpl_1: qui logit moving_cnty $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl `intpop') l.($z1 $z2nb $z3nb) i.sic2digm i.year i.stateID, vce(cluster tractID)
eststo cntyintpl_2: qui logit moving_cnty $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl `intedu') l.($z1 $z2nb $z3nb) i.sic2digm i.year i.stateID, vce(cluster tractID)
eststo intctpl_1: qui logit moving_ct $m2nb $m31nb $m1nb l.($x1 $x2) (sp* zero_tl `intpop') l.($z2nb $z31nb) i.sic2digm i.year i.stateID if maxmove_cnty == 0 & lgwageindcnty ~= . & lgempcnty ~= . & voterturnout1990 ~= ., cluster(tractID) 
eststo intctpl_2: qui logit moving_ct $m2nb $m31nb $m1nb l.($x1 $x2) (sp* zero_tl `intedu') l.($z2nb $z31nb) i.sic2digm i.year i.stateID if maxmove_cnty == 0 & lgwageindcnty ~= . & lgempcnty ~= . & voterturnout1990 ~= ., cluster(tractID)  

esttab intpl_1 intpl_2 cntyintpl_1 cntyintpl_2 intctpl_1 intctpl_2 using Table10.csv, replace /// 
	drop(*.sic2digm *.stateID *.year) ///
	mtitle("All Moves" "" "Cross Cnty" "" "Within Cnty" "") ///
	label interaction(" x ") b(3) ar2 se star(* 0.10 ** 0.05 *** 0.01) ///
	nogap nodep nonotes compress 


* ------------------------------------------
* Table B12. Heterogeneity across Industries
* ------------------------------------------
preserve 
replace sic2digm = 100 if inlist(sic2digm, 0, 16, 17, 42, 49, 50, 51, 59, 73, 76, 87)

eststo indFE: logit moving_ctcnty c.lgpopdensity_ctnb1990#ib100.sic2digm c.edu3_rate_ctnb1990#ib100.sic2digm $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID ib100.sic2digm i.year, vce(cluster tractID)

eststo indFEcnty: logit moving_cnty c.lgpopdensity_ctnb1990#ib100.sic2digm c.edu3_rate_ctnb1990#ib100.sic2digm $m2nb $m3nb $m1nb l.($x1 $x2) (sp* zero_tl) l.($z1 $z2nb $z3nb) i.stateID ib100.sic2digm i.year, vce(cluster tractID)

eststo indFEct: logit moving_ct c.lgpopdensity_ctnb1990#ib100.sic2digm c.edu3_rate_ctnb1990#ib100.sic2digm $m2nb $m31nb $m1nb l.($x1 $x2) (sp* zero_tl) l.($z2nb $z31nb) i.stateID ib100.sic2digm i.year if maxmove_cnty == 0 & lgwageindcnty ~= . & lgempcnty ~= . & voterturnout1990 ~= ., vce(cluster tractID)

esttab indFE indFEcnty indFEct using TableB12.csv, append ///
	drop(*.sic2digm *.stateID) ///
	label interaction(" x ") b(3) ///
	nogap nodep nonotes compress se ar2 star(* 0.10 ** 0.05 *** 0.01)
restore 